<template>
    <div>
<van-nav-bar title="分类" />
<!-- 设置垂直间距 -->
<van-row>
  <van-col span="6">
    <van-sidebar v-model="active">
  <van-sidebar-item :title="key.cat_name" v-for="key in categories"/>
</van-sidebar>

  </van-col>
  <van-col span="18">
    <div v-for="key in categories[active]?.children">
        <h4>{{key.cat_name}}</h4>
        <router-link :to="'/goods/'+key.cat_name">
<van-grid :column-num="4">
  <van-grid-item v-for="value in key.children" :key="value" :icon="value.cat_icon" :text="value.cat_name" />
</van-grid>
</router-link>
    </div>
  </van-col>
</van-row>

    </div>
</template>

<script setup>
import { ref } from "vue"
  const active = ref(0);
import { categoriesApi } from "@/api/api";
let categories=ref([])
categoriesApi().then(res=>{
    console.log('fen',res);
    categories.value=res.data.message
})
</script>

<style lang="scss" scoped>

</style>